package com.bawei.lookfor2204a.view.activity.watch

import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import com.bawei.lookfor2204a.model.FindAllGiftBean
import com.bawei.lookfor2204a.model.HttpUtils
import com.bawei.lookfor2204a.model.MessageBean
import com.bawei.lookfor2204a.model.WatchLiveBean
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers

/**
 * 作者：赵亮
 * 时间：2024/10/16 12:15
 * 功能：观看直播和录播的View Model
 */
class WatchViewModel : ViewModel() {

    // 聊天室数据
    val messageList = mutableListOf(
        MessageBean("https://pics0.baidu.com/feed/72f082025aafa40f1e91cf8f819a3d4179f0191c.jpeg?token=81bcc4eecc0fceebc7ac9760f34f815e", "猪八戒", "大叫好"),
        MessageBean("https://pics0.baidu.com/feed/72f082025aafa40f1e91cf8f819a3d4179f0191c.jpeg?token=81bcc4eecc0fceebc7ac9760f34f815e", "猪八戒", "大叫好"),
        MessageBean("https://pics0.baidu.com/feed/72f082025aafa40f1e91cf8f819a3d4179f0191c.jpeg?token=81bcc4eecc0fceebc7ac9760f34f815e", "猪八戒", "大叫好"),
        MessageBean("https://pics0.baidu.com/feed/72f082025aafa40f1e91cf8f819a3d4179f0191c.jpeg?token=81bcc4eecc0fceebc7ac9760f34f815e", "猪八戒", "大叫好"),
        MessageBean("https://pics0.baidu.com/feed/72f082025aafa40f1e91cf8f819a3d4179f0191c.jpeg?token=81bcc4eecc0fceebc7ac9760f34f815e", "猪八戒", "大叫好"),
        MessageBean("https://pics0.baidu.com/feed/72f082025aafa40f1e91cf8f819a3d4179f0191c.jpeg?token=81bcc4eecc0fceebc7ac9760f34f815e", "猪八戒", "大叫好"),
        MessageBean("https://pics0.baidu.com/feed/72f082025aafa40f1e91cf8f819a3d4179f0191c.jpeg?token=81bcc4eecc0fceebc7ac9760f34f815e", "猪八戒", "大叫好")
    )

    // 观看直播
    val watchLiveSuccess = MutableLiveData<WatchLiveBean>()
    fun watchLive(
       liveId:Int
    ) {
        HttpUtils.HttpUtils.apiService.watchLive(liveId)
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe { watchLiveSuccess.postValue(it) }
    }

    // 查询所有礼物
    val findAllGiftSuccess = MutableLiveData<FindAllGiftBean>()
    fun findAllGift() {
        HttpUtils.HttpUtils.apiService.findAllGift()
            .subscribeOn(Schedulers.io())
            .observeOn(AndroidSchedulers.mainThread())
            .subscribe { findAllGiftSuccess.postValue(it) }
    }
}